import { SessionItem } from '@/models/sessionItem';
import { request } from 'umi';

export async function login(username: string, password: string) {
  return request<ApiResponse.ResultModel<TokenInfo>>('/api/authenticate/Login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {
      username: username,
      prefix: "tfadmin",
    },
    data: password
  });
}

export async function authInfo() {
  return request<ApiResponse.ResultModel<AdminUserType.AuthInfo>>('/api/authenticate/AuthInfo', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
    },
  });
}


export async function putSessionItem(sessionItem: SessionItem) {
  return request<ApiResponse.ResultModel<SessionItem>>(`/api/sessionitems/put`, {
    method: 'put',
    headers: {
      'Content-Type': 'application/json',
    },
    data: sessionItem,
  });
}

export async function deleteSessionItem(id: string) {
  return request<ApiResponse.ResultModel<boolean>>(`/api/sessionitems/delete`, {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    params: {
      id: id
    },
  });
}
